mod local_json_file;
mod my_commands;
mod system_tray;
mod window_event;

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    let mut builder = tauri::Builder::default()
        .on_window_event(window_event::handle_window_event)
        .on_tray_icon_event(system_tray::handle_tray_icon_event)
        .plugin(tauri_plugin_process::init())
        .plugin(tauri_plugin_updater::Builder::new().build())
        .plugin(tauri_plugin_fs::init())
        .plugin(tauri_plugin_window_state::Builder::new().build())
        .plugin(tauri_plugin_dialog::init())
        .plugin(tauri_plugin_opener::init())
        .invoke_handler(tauri::generate_handler![
            my_commands::read_local_settings,
            my_commands::open_path,
            my_commands::check_path_existence,
            my_commands::check_path_type,
            my_commands::save_local_setting,
            my_commands::get_file_icon_base64,
            my_commands::exit_app,
        ]);

    if cfg!(not(debug_assertions)) {
        // Disabeld default context menu and all shortcuts in release build.
        builder = builder.plugin(tauri_plugin_prevent_default::init());
    }

    builder
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
